<!doctype html>
[#escape x as (x)!?html]
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>${investigate.title} - ${site.seoTitle} - Powered by JPROCMS</title>
  <meta name="keywords" content="${site.seoKey}">
  <meta name="description" content="${site.seoDesc}">
  [#include '../includes/common_res.html'/]
</head>
<body>
[#assign shadowNav=true/]
[#include '../includes/header.html'/]
[#include '../includes/inc_msg.html'/]
<div class="bg-gray-200">
  <div class="container">
    <nav class="row" aria-label="breadcrumb">
      <ol class="col list-inline my-2">
        <li class="list-inline-item"><a href="${site.url}">首页</a></li>
        <li class="list-inline-item">/</li>
        <li class="list-inline-item"><a href="${base}/investigate">网络调查</a></li>
      </ol>
    </nav>
  </div>
</div>
<div class="container mt-4">
  <h3>${investigate.title}</h3>
  <div class="mt-2 pb-2 border-bottom text-muted">
    <div>
      <span>${ZFormat(investigate.createTime, 'yyyy-MM-dd HH:mm')}</span>
      [#if investigate.status == 0]
      <span class="ml-2 badge badge-success">进行中</span>
      [#elseif investigate.status == 1]
      <span class="ml-2 badge badge-secondary">未启用</span>
      [#elseif investigate.status == 2]
      <span class="ml-2 badge badge-warning">未开始</span>
      [#elseif investigate.status == 3]
      <span class="ml-2 badge badge-info">已结束</span>
      [#else]
      <span class="ml-2 badge badge-danger">未知状态</span>
      [/#if]
      <i class="ml-2 fas fa-vote-yea text-primary" title="参与人次"></i> <span>${investigate.joinNum}</span>
    </div>
    [#if investigate.description??]
    <div class="mt-2 small">${investigate.description}</div>
    [/#if]
  </div>
  <form id="investigateForm" action="${api}/investigate/vote" method="post">
    [#list investigate.items as item]
    <div class="mt-4"><span>${item_index+1}.</span><label class="ml-3" for="item-${item.id?c}-essay">${item.title}</label></div>
    <div class="ml-4">
      [#if item.isQa]
      <div class="mt-2">
        <textarea id="item-${item.id?c}-essay" name="items[${item.id?c}]" class="form-control" rows="3" required></textarea>
      </div>
      [#else]
      <div class="small check-group">
        [#list item.options as option]
        <div class="form-check mt-2 text-muted ">
          <input class="form-check-input" type="${item.isMultiple?string('checkbox','radio')}" name="items[${item.id?c}]" id="investigate-${item.id?c}-${option_index?c}" value="${option.id?c}" required>
          <label class="form-check-label" for="investigate-${item.id?c}-${option_index?c}">
            ${option.title}
          </label>
        </div>
        [/#list]
      </div>
      [/#if]
    </div>
    [/#list]
    <input type="hidden" name="id" value="${investigate.id?c}">
    <div class="mt-4 text-center">
      <button type="submit" class="btn btn-primary btn-sm">提交</button>
      <a href="${base}/investigate/${investigate.id?c}/result" class="ml-2 btn btn-outline-danger btn-sm">查看结果</a>
    </div>
  </form>
  <script>
    $('#investigateForm').validate({
      submitHandler: function (form) {
        request.post(form.action, $(form).serializeJSON()).then(function (response) {
          var data = response.data;
          if (data.code === 0) {
            alertShow('提交成功');
            $('#investigateForm')[0].reset();
          } else if (data.msg) {
            alertShow(data.msg);
            $('#investigateForm')[0].reset();
          }
        });
      }
    });
  </script>
</div>
[#include '../includes/footer.html'/]
</body>
</html>
[/#escape]
